home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!panix!not-for-mail
- From: acinader@panix.com (Arthur Cinader Jr)
- Newsgroups: gnu.g++.help,comp.lang.c++
- Subject: IS THIS LEGAL? Static method returns pointer to class
- Date: 4 Mar 1996 00:14:08 -0500
- Organization: Panix
- Message-ID: <4hdu70$efa@panix.com>
- NNTP-Posting-Host: panix.com
-
- I may be going at this wrong, but I want to have a class
- Triangle contain a static method called makeinstance. The
- method will be passed a refernce to a Param object that has
- a list of parameters for checking first and then passing to
- the Triangle constructor.
-
- The parameters are checked and if all is ok, a Triangle
- instance is "newed" and the pointer to the new Trinagle is
- returned. When I compile, I get the following error:
-
- % g++ -c triangle.C
- In file included from triangle.C:8:
- triangle.h:17: syntax error before `*'
- ...
- %
-
- ***The declaration for the class:
-
- 1 // triangle.h
- 2 // declaration of class Triangle extends shape
- 3
- 4 #ifndef TRIANGLE_H
- 5 #define TRIANGLE_H
- 6
- 7 #include "point.h"
- 8 #include "param.h"
- 9
- 10 class Trianlge : public Point {
- 11 public:
- 12 Trinagle(float = 0.0, float = 0.0, float = 0.0);
- 13 float gets() const;
- 14 virtual void draw() const;
- 15
- 16 static Param &getParams();
- 17 static Triangle *makeinstance(Param &);
- 18 private:
- 19 float side;
- 20 };
- 21
- 22 #endif
-